package org.game.module.fight.handler;

import org.cfg.DungeonLevelCfg;
import org.cfg.DungeonLevelGroupCfg;
import org.game.db.bean.DungeonLevel;
import org.game.db.bean.DungeonLevelGroup;
import org.game.db.bean.Player;
import org.game.manager.DungeonManager;
import org.game.module.dungeonbo.DungeonBO;
import org.game.module.fight.AbstractFight;
import org.game.module.fight.dungeom.DungeonCheck;
import org.game.msgBuilder.DungeonMsgBuilder;

/**
 * @author : DengYing
 * @CreateDate : 2018年8月14日 下午7:59:23
 * @Description ：活动关卡
 */
public class ActivityDungeonHandler extends DungeonFightHandler{
	
	public ActivityDungeonHandler(Player player, DungeonLevelCfg cfg, DungeonLevel dungeonLevel,DungeonLevelGroupCfg dungeonLevelGroupCfg) {
		super(player, cfg, dungeonLevel, dungeonLevelGroupCfg);
	}



	@Override
	public boolean startCheck(AbstractFight fight) {
		DungeonCheck.checkLevelGroupIsOpenTime(dungeonLevelGroupCfg);
		DungeonCheck.checkLevelGroupFightCount(player, dungeonLevelGroupCfg);
		
		DungeonCheck.checkPlayerLevel(player,cfg);
		DungeonCheck.checkPreLevel(player, cfg);
		DungeonCheck.checkCost(player, cfg);
		DungeonCheck.checkFightCount(cfg, dungeonLevel);
		return true;
	}

	

	@Override
	public void fightWin(AbstractFight fight) {
		super.fightWin(fight);
		
		DungeonLevelGroup group = DungeonManager.getOrInitDungeonLevelGroup(player,dungeonLevel.getDungeonLevelProxy().getCfg().getLevelGroupId());
        group.setFightCount(group.getFightCount() + 1);
        group.update();
        player.getPlayerProxy().sendMsg(DungeonBO.updateLevelGroupInfo, DungeonMsgBuilder.getUpdateLevelGroupInfo(group));
	}
}
